First it has to be said that by distance from any point to any line, I am speaking only about 2-dimensions and the shortest or perpendicular distance. So, let's start with line $$y=mx+b_{1} \tag{EQ 1} \label{EQ 1}$$ (the red line containing point $P$ in figure Orthogonal-Lines) and point $C(h,k)$, which is not on the line. We will change to the perpendicular slope, $(-1/m)$ and use $(h,k)$ to write the perpendicular line. In point slope form, it is $$y-k=\left(\frac{-1}{m}\right)\left(x-h\right). \tag{EQ 2} \label{EQ 2}$$ Equation $\eqref{EQ 1}$ is a line that passes through $(h,k)$ and is perpendicular to $y=mx+b_{1}$. Now we can solve the two simultaneous equations, $\eqref{EQ 1}$ and $\eqref{EQ 2}$ to find their intersection. These can be solved by hand quite easily to give point $E$. $$\begin{array}{cccc} x_{1}={\displaystyle \frac{mk-mb_{1}+h}{m^{2}+1}} & \quad & \quad & y_{1}={\displaystyle \frac{km^{2}+hm+b_{1}}{m^{2}+1}}\end{array} \tag{EQ 3} \label{EQ 3}$$ If equation $\eqref{EQ 1}$ had been given in point slope form, it would be $$y-P_{y}=m\left(x-P_{x}\right)$$ and its solutions would be $$x_{1}=\frac{P_{x}\;m^{2}-P_{y}\;m+h+k\;m}{m^{2}+1},\qquad y_{1}=\frac{-P_{x}\;m+P_{y}+h\;m+k\;m^{2}}{m^{2}+1}$$ The new point $E(x_{1,},y_{1})$ represents a point on the line $y=mx+b_{1}$ which is the closest point to $(h,k)$. The next step is to get the distance from $(h,k)$ to $(x_{1},y_{1})$. $$\text{distance from C to E}=\sqrt{\left(h-x_{1}\right)^{2}+\left(k-y_{1}\right)^{2}}$$ With more than a little algebra, this can be expressed as $$\text{distance from C to E}=\frac{\left\Vert hm+b_{1}-k\right\Vert }{\sqrt{m^{2}+1}} =\frac{\left\Vert hm-P_{x}m+P_{y}-k\right\Vert }{\sqrt{m^{2}+1}} \tag{EQ 4} \label{EQ 4}$$